﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CRM.Controller;
using CRM.Entity.Extra;

namespace CRM.Web.Admin
{
    public partial class news : System.Web.UI.Page
    {
        ArticleInfoController articleInfoController = new ArticleInfoController();
        public string pics = "''";
        public string links = "''";
        public string texts = "''";
        protected void Page_Load(object sender, EventArgs e)
        {
            pics = "'images/NewsPic/1.jpg'" + "+ '|' +" + "'images/NewsPic/2.jpg'" + " + '| '+" + "'images/NewsPic/3.jpg'" + "+ '| '+" + "'images/NewsPic/4.jpg'";
            //links = "'Img.aspx'" + "+ '|' +" + "'1/4.jpg'" + " + '| '+" + "'1/2.jpg'" + "+ '| '+" + "'1/3.jpg'";
            //texts = "'标题'" + "+ '|' +" + "'1/4.jpg'" + " + '| '+" + "'1/2.jpg'" + "+ '| '+" + "'1/3.jpg'";
            if (!IsPostBack)
            {
                BindData();
            }
        }

        protected void BindData()
        {
            var pageIndex = 1;
            var pageSize =5;
            var pageInfo = new PageInfo()
            {
                PageIndex = pageIndex,
                PageSize = pageSize
            };

            var articleInfo = articleInfoController.GetListExtra(pageInfo, 1);
            int SummaryLength = 100; //概要长度
            if (articleInfo.ListEntity != null)
            {
                foreach (var info in articleInfo.ListEntity)
                {
                    info.ArticleContent = Common.DelHTML.DelHtml(info.ArticleContent);
                    SummaryLength = info.ArticleContent.Length > 100 ? 100 : info.ArticleContent.Length;
                    info.ArticleContent = System.Web.HttpUtility.HtmlEncode(info.ArticleContent.Substring(0, SummaryLength) + "......");
                }
                this.rpNewsList.DataSource = articleInfo.ListEntity;
                this.rpNewsList.DataBind();
            }
        }
    }
}